<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        
        <title><?php echo config_item('site_title'); ?> - View Post</title>
		
		<script src="<?php echo base_url(); ?>application/assets/js/jquery.js"></script>
		<script src="<?php echo base_url(); ?>application/assets/js/jquery-1.6.4.min.js"></script>	
		<script src="<?php echo base_url(); ?>application/jquery/jquery-ui-1.8.13.custom.min.js"></script>
		
		<link href="<?php echo base_url(); ?>application/jquery/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet">
		
		<!-- Rich Text Editor -->
		<link href="<?php echo base_url(); ?>application/assets/css/bootstrap-wysihtml5.css" rel="stylesheet">
		<script src="<?php echo base_url(); ?>application/assets/js/wysihtml5-0.3.0.js"></script>
		<script src="<?php echo base_url(); ?>application/assets/js/bootstrap.min.js"></script>		
		<script src="<?php echo base_url(); ?>application/assets/js/bootstrap-wysihtml5.js"></script>
		
		<link href="<?php echo base_url(); ?>application/assets/css/bootstrap.css" rel="stylesheet">
        <style type="text/css">
            body {
				padding-top: 80px;
				padding-bottom: 60px;
				background-color: #f5f5f5;
			  }
			  			  
			  #footer {
			   position:fixed;
			   left:0px;
			   bottom:-20px;
			   height:30px;
			   width:100%;
			}
			li {
				line-height: 15px;
			}
			.textbox {
				box-shadow:1px 1px 8px 1px #B8B8B8;
				padding:10pt;
				margin-top:10pt;
				margin-bottom:10pt;
				min-height:200pt;
			}
			#addlinfo div {
				padding-top: 8pt;
			}

			/* Styles for custom vertical scrollbar */
			::-webkit-scrollbar {
			    width: 10px;
			}
			::-webkit-scrollbar-track {
			    background: #FFF;
			    -webkit-box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
			}
			::-webkit-scrollbar-thumb {
			    background: #CCC;
			    -webkit-box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2);
			}
			::-webkit-scrollbar-thumb:hover {
			    background: #AAA;
			}
			::-webkit-scrollbar-thumb:active {
			    background: #888;
			    -webkit-box-shadow: inset 1px 1px 2px rgba(0,0,0,0.3);
			}
        </style>
        <link href="<?php echo base_url(); ?>application/assets/css/bootstrap-responsive.css" rel="stylesheet">

        <script type="text/javascript">
			$(document).ready(function() {
				$('#articlecontents').wysihtml5({
					"font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
					"emphasis": true, //Italics, bold, etc. Default true
					"lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true
					"html": false, //Button which allows you to edit the generated HTML. Default false
					"link": true, //Button to insert a link. Default true
					"image": true, //Button to insert an image. Default true,
					"color": false //Button to change color of font  
				});
            });
			
			function save() {
				if($("#articlecontents").val() == '') {
					$("#error").show(300);
				} else {
					$("#form1").submit();
				}
			}

        </script>
	</head>
	<body>
		<?php
			$sessiondata = $this->session->userdata('username');
			if((isset($sessiondata)) && ($sessiondata != '')) {
			echo getTopNav();
			$data = $article;
		?>
		
		<div class="container">
                <div class="row-fluid">                        
					<div class="span9">
                        <div class="well1" style="height:400px;">
							<div id="error" class="alert alert-error" style="display:none;">
								<button type="button" class="close" data-dismiss="alert">&times;</button>
								Nothing to save !
							</div>

                        	<form id="form1" accept-charset="UTF-8" action="<?php echo base_url(); ?>Articles/save" method="POST">
								
						        
								<?php if(isset($article)) { ?>
								<textarea class="span12" id="articlecontents" name="articlecontents"
						        placeholder="Type in your message" rows="25"><?php echo $article[0]->article; ?></textarea>
								<?php }	?>
													        
						        
						        <div class="pull-right">
						        	<span><i class="icon-th-list"></i>&nbsp;Category &nbsp;</span>
						        	<?php getCategorySelBox('category', 'category', $article[0]->categoryid)  ?>
						    	</div>

						        <button class="btn btn-success" type="button" onclick="save()">Save</button>
			        			<a href="<?php echo base_url(); ?>Home" class="btn btn-secondary">Cancel</a>

						        <!-- hidden variables -->
						        <input type="hidden" id="userid" name="userid" value="<?php echo $this->session->userdata('userid'); ?>">
								<input type="hidden" id="articleid" name="articleid" value="<?php echo $article[0]->id; ?>">
						    </form>

						</div>
                    </div><!--/span-->
					
					

			        <div class="span3">
				    	
				    	<div id="addlinfo" class="textbox muted well" style="margin-top:30pt">
				    		<?php 
			        			if(isset($article)) {
				        			foreach($article as $item) {
				        				echo '<div><strong>Posted By:</div><div></strong> ' . $item->uname . '</div>';
				        				echo '<div><strong>Posted on:</div><div></strong> ' . $item->createdon . '</div>';
										echo '<div><strong>Modified on:</div><div></strong> ' . $item->lastmodifiedon . '</div>';
				        				echo '<div><strong>Viewed:</strong> ' . $item->cnt_view . ' times</div>';
							    		echo '<div><strong>Likes:</strong> 4 </div>';
							    		echo '<div><strong>Character Count:</strong> ~ ' . strlen($item->article) . '</div>';
				        			}
			        			}
			        		?>


				    	</div>
				    </div>
                </div><!--/row-->
				
                <!-- Include footer -->
                <?php include 'footer.php' ?>
            </div>
            			
			<!-- Hidden variables -->
			<input type="hidden" id="baseurl" name="baseurl" value="<?php echo base_url(); ?>">
	
	<?php
		} else {
			redirect('Login');
		}
	?>
	</body>
	
	<!-- Placed at the end of the document so the pages load faster -->
    
			
</html>